<?php
/*
 *      index.php
 *      
 *      Copyright 2009 Valery Tverdohleb <tvsdesign@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

header('Content-type:text/html; charset=UTF-8');

require_once "lib/engine.class.php";

Engine::get()->smarty->assign('title',STR::$str['game_name']);

switch (Engine::get()->router->route['leadsto'])
{
	case 'CIdle':
	{
		if (isset($_POST['m']) && ($_POST['m'] == 'login'))
		{
			Engine::get()->access->login($_POST['login'],$_POST['password']);
		}
		if (isset($_POST['m']) && ($_POST['m'] == 'logout'))
		{
			Engine::get()->access->logout();
		}
		$controller = ControllerIdle::Create();
		break;
	}
	case 'CRegister':
	{
		$controller = ControllerRegister::Create();
		break;
	}
	default:
	{
		throw new Service_Exception('There are no controllers named '.Engine::get()->router->route['leadsto']);
	}
}

$controller->Render();

?>
